#!/usr/bin/python
#coding=utf-8
import os
import urllib
import sys
import re


#oppo = 'http://bbs.coloros.com/forum.php?mod=phones&code=rom&pid=125'
def read_roms(url):

	page = urllib.urlopen(url)

	html = page.read()
	page.close()

	if html.find('此产品不存在') > 0:
		return
	
	#print url

	#rom_pattern = re.compile(r'http:\/\/firmware.meizu.com\/Firmware\/Flyme\/.*update.zip')
	rom_pattern = re.compile(r'"(http:[^"]+(download|firmware).meizu.com[^"]+Firmware[^"]+Flyme[^"]+update.zip)"')

        rom_list = rom_pattern.findall(html)

        if rom_list != []:
	    for r in rom_list:
                link = r[0].replace("\/", "/")
		print link

for i in range(7, 106):
	u = 'http://www.flyme.cn/firmwarelist-%d.html#3' % i
	read_roms(u)
